import rtconfig
from building import *

cwd = GetCurrentDir()

src = ['src/stm32l4xx_hal.c',
       'src/stm32l4xx_hal_cortex.c',
       'src/stm32l4xx_hal_pwr.c',
       'src/stm32l4xx_hal_pwr_ex.c',
       'src/stm32l4xx_hal_rcc.c',
       'src/stm32l4xx_hal_rcc_ex.c',
       'src/stm32l4xx_hal_tim.c',
       'src/stm32l4xx_hal_tim_ex.c',
       'src/stm32l4xx_hal_dma.c',
       'src/stm32l4xx_hal_flash.c',
       'src/stm32l4xx_hal_flash_ex.c']

path = [cwd + '/inc']

CPPDEFINES = ['USE_HAL_DRIVER', rtconfig.STM32_TYPE]

if GetDepend(['RT_USING_PIN']):
    src += ['src/stm32l4xx_hal_gpio.c']
    
if GetDepend(['RT_USING_I2C']):
    src += ['src/stm32l4xx_hal_i2c.c']
    src += ['src/stm32l4xx_hal_i2c_ex.c']
    
if GetDepend(['RT_USING_PM']):
    src += ['src/stm32l4xx_hal_lptim.c']
    
if GetDepend(['RT_USING_SPI']):
    src += ['src/stm32l4xx_hal_spi.c']
    src += ['src/stm32l4xx_hal_qspi.c']
    
if GetDepend(['RT_USING_SERIAL']):
    src += ['src/stm32l4xx_hal_uart.c']
    src += ['src/stm32l4xx_hal_uart_ex.c']
     
if GetDepend(['RT_USING_USB_DEVICE']):
    src += ['src/stm32l4xx_hal_pcd.c']
    src += ['src/stm32l4xx_hal_pcd_ex.c'] 
    src += ['src/stm32l4xx_ll_usb.c']

if GetDepend(['RT_USING_AUDIO']):
    src += ['src/stm32l4xx_hal_sai.c']

group = DefineGroup('STM32L4xx_HAL_Driver', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)

Return('group')
